import struct
import socket
a=b'\x83\x00\x00\x00\x83\x00\x00\x00\xb2\x02\x00\x00type@=loginres/userid@=1300242584/roomgroup@=183148656/sessionid@=341699280/username@=\xe6\xb8\xb8\xe5\xae\xa2212584/nickname@=\xe6\xb8\xb8\xe5\xae\xa2212584/'
b=b'\xa0\x01\x00\x00\xa0\x01\x00\x00\xb2\x02\x00\x00type@=msgrepeaterlist/rid@=8786/list@=id@AA=70003@ASnr@AA=1@AScl@AA=6047@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27001@AS@Sid@AA=70002@ASnr@AA=2@AScl@AA=1588@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27002@AS@Sid@AA=70004@ASnr@AA=1@AScl@AA=6008@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27002@AS@Sid@AA=70001@ASnr@AA=2@AScl@AA=1613@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27001@AS@S/\x00,\x00\x00\x00,\x00\x00\x00\xb2\x02\x00\x00type@=setmsggroup/rid@=8786/gid@=0/\x00'
bdatas=b'type@=msgrepeaterlist/rid@=8786/list@=id@AA=70003@ASnr@AA=1@AScl@AA=6047@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27001@AS@Sid@AA=70002@ASnr@AA=2@AScl@AA=1588@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27002@AS@Sid@AA=70004@ASnr@AA=1@AScl@AA=6008@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27002@AS@Sid@AA=70001@ASnr@AA=2@AScl@AA=1613@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27001@AS@S/'
dedatas='type@=msgrepeaterlist/rid@=8786/list@=id@AA=70003@ASnr@AA=1@AScl@AA=5882@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27001@AS@Sid@AA=70002@ASnr@AA=2@AScl@AA=1633@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27002@AS@Sid@AA=70004@ASnr@AA=1@AScl@AA=5753@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27002@AS@Sid@AA=70001@ASnr@AA=2@AScl@AA=1599@ASml@AA=10000@ASip@AA=danmu.douyu.tv@ASport@AA=27001@AS@S/'
c=b'\x00,\x00\x00\x00,\x00\x00\x00\xb2\x02\x00\x00type@=setmsggroup/rid@=8786/gid@=0/\x00'



a=b'\x82\x00\x00\x00\x82\x00\x00\x00\xb2\x02\x00\x00type@=loginres/userid@=1300255591/roomgroup@=93342000/sessionid@=341699280/username@=\xe6\xb8\xb8\xe5\xae\xa2225591/nickname@=\xe6\xb8\xb8\xe5\xae\xa2225591'

n='游客225591'

c='type@=loginreq/%s/password@=/roomid@=8786/\000'









Nip=socket.gethostbyname("danmu.douyu.tv")
Nport=27001
rid=8786
uname='username@=游客238076'
datas2='type@=loginreq/%s/password@=/roomid@=%s/\000'%(uname,rid)
print('len-datas2:',len(datas2))
fmt2='iih2s%ss'%len(datas2)#发送格式
changdu2=2*3+2+len(datas2)
baochangdu=changdu2
so2=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
so2.connect((Nip,Nport))
S2data=struct.pack(fmt2,baochangdu,changdu2,689,b'',datas2.encode("utf8"))
so2.send(S2data)
print(so2.recv(1024))


